package array

var res77 [][]int

func helper77(n int, k int, start int, track []int) {
	// 满足条件了
	if len(track) == k {
		// temp := []int{} 这样不行
		temp := make([]int, k)
		copy(temp, track) //深拷贝
		res77 = append(res77, temp)
		return
	}

	// 可用的数量不够
	if k-len(track) > n-start+1 {
		return
	}

	for i := start; i <= n; i++ {
		track = append(track, i)
		helper77(n, k, i+1, track)
		track = track[:len(track)-1]
	}
}

func combine(n int, k int) [][]int {
	res77 = [][]int{}
	helper77(n, k, 1, []int{})
	return res77
}
